﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using SayDemo.Models;

namespace SayDemo.Data
{
    public class ExamDemoDbInitilizer:DropCreateDatabaseAlways<ExamDemoDb>
    {
        protected override void Seed(ExamDemoDb db)
        {
            db.Users.Add(new Models.Users
            {
                Username = "帅辉",
                Password = "123",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version=0

            });
            db.Users.Add(new Models.Users
            {
                Username = "帅陶",
                Password = "123456",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
            });
            db.Users.Add(new Models.Users
            {
                Username = "麻花",
                Password = "123456",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
            });
            db.Messages.AddRange(new List<Messages>
            {
                new Messages
                {
                    FromUserId = 1,
                    Content= "我去你妈的",
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                    Version = 0
                },
                new Messages
                {
                    FromUserId = 2,
                    Content= "干",
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                    Version = 0
                },
                new Messages
                {
                    FromUserId = 3,
                    Content= "妈的",
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                    Version = 0
                },

            });
            db.Comments.AddRange(new List<Comments>
            {
                new Comments
                {
                    MsgId = 2,
                    FromUserId = 1,
                    Content = "妈卖批",
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                    Version = 0
                },
                new Comments
                {
                    MsgId = 1,
                    FromUserId = 1,
                    Content = "妈卖批",
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                    Version = 0
                },
                new Comments
                {
                    MsgId = 1,
                    FromUserId = 3,
                    Content = "妈卖批",
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                    Version = 0
                }
            });
            db.SaveChanges();
                
            base.Seed(db);
        }
    }
}